<?php
/**
 * @author spenceryg
 * @date 2023/4/9
 * @time 12:24 上午
 * @focus love & life
 */


namespace app\api\controller;

use app\common\model\PointProducts;
use chillerlan\QRCode\QRCode;
use hg\apidoc\annotation as Apidoc;

/**
 * Class Products
 * @package app\api\controller
 * @Apidoc\Title("商品管理")
 * @Apidoc\Group("api")
 */
class Products extends Auth
{
    /**
     * getList
     * @Apidoc\Title("积分商品列表")
     */
    public function getList()
    {
        $is_integral = input('is_integral', 0, 'intval');
        $res = PointProducts::order('sort asc')
            ->where('is_integral',$is_integral )
            ->select();
        $res = $res->toArray();
        foreach ($res as $index => $item) {
            $url = config('wechat.base_url') . '/api/PointPay/checkTerrace?member_id=' . $this->request->uid . '&id=' . $item['id'];
            $img = (new QRCode)->render($url);
            $item['images'] = $img;
            $res[$index] = $item;
        }
        return success('', $res);
    }
}
